<template>
<!-- 海外设计单位 -->
  <div>
    <title-name title="考察海外设计单位信息"></title-name>
    <a-form-model :model="companyDetList" :rules="validRules" ref="validForm">
      <a-row>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="考察设计资源名称"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseInput v-model="companyDetList.surveyName" disabled
                    placeholder="请输入" />
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="联系人姓名"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseInput  v-model="companyDetList.contactName" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入" />
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="联系人电话"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"  prop='contactPhone'>
            <BaseInput  v-model="companyDetList.contactPhone" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入"  />
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="公司传真"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"  prop="fax">
            <BaseInput  v-model="companyDetList.fax" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入" />
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="企业性质"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseInput  v-model="companyDetList.natureOfOverseasCompany" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入" />
            <!-- <a-select :getPopupContainer="getPopupContainer" v-model="companyDetList.natureOfEnterpriseId" placeholder="请选择" :disabled="type=='view'|| type=='approve'">
              <a-select-option v-for="item in companyList" :key="item.id">{{item.name}}</a-select-option>
            </a-select> -->
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="公司注册时间"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <a-date-picker  v-model="companyDetList.registrationDate" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入" />
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="法定资本(万)"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseInputNumber :min='1'  v-model="companyDetList.registeredCapital" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入" />
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="企业法人代表人姓名"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseInput  v-model="companyDetList.legalName" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入" />
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="法人代表电话号码"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"  prop="legalContact">
            <BaseInput  v-model="companyDetList.legalContact"   placeholder="请输入"  :disabled="type=='view'|| type=='approve'" />
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="企业代码"
                  :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseInput  v-model="companyDetList.creditCode" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入" />
          </a-form-model-item>
        </a-col>
        <a-col :md="24" :sm="24">
          <a-form-model-item
                  label="企业地址"
                  :labelCol="{ lg: { span: 4 }, sm: { span: 4 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseTextarea  v-model="companyDetList.address" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入" />
          </a-form-model-item>
        </a-col>
        <a-col :md="24" :sm="24">
          <a-form-model-item
                  label="设计院专长类型"
                  :labelCol="{ lg: { span: 2 }, sm: { span: 2 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseTextarea  v-model="companyDetList.specialtyType" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入"  />
          </a-form-model-item>
        </a-col>
        <a-col :md="24" :sm="24">
          <a-form-model-item
                  label="承揽项目范围"
                  :labelCol="{ lg: { span: 2 }, sm: { span: 2 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseTextarea  v-model="companyDetList.projectRange" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入"  />
          </a-form-model-item>
        </a-col>
        <a-col :md="24" :sm="24">
          <a-form-model-item
                  label="综合管理水平及履约能力"
                  :labelCol="{ lg: { span: 2 }, sm: { span: 2 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseTextarea  v-model="companyDetList.comManageLevel" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入"  />
          </a-form-model-item>
        </a-col>
        <a-col :md="24" :sm="24">
          <a-form-model-item
                  label="技术能力及设计质量管理情况"
                  :labelCol="{ lg: { span: 2 }, sm: { span: 2 } }"
                  :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }">
            <BaseTextarea  v-model="companyDetList.techQualityInfo" :disabled="type=='view'|| type=='approve'"
                    placeholder="请输入"  />
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
    


    <title-name style="margin-top:20px" title="企业主要骨干人员"></title-name>
    <!-- <a-card :bordered="false" style="over-flow:scroll"> -->
    <div>
      <a-row>
        <div class="table-operator">
          <a-row>
            <a-col :md="24" :sm="24">
              <a-button type="primary"  :disabled="type=='view'|| type=='approve'" @click="openMainMember()">新增人员</a-button>
              <a-button type="info" :disabled="type=='view'|| type=='approve'"  @click="delMember()">删除</a-button>
            </a-col>
          </a-row>
        </div>
        <a-table
                rowKey="id"
                :columns="columns1"
                :rowSelection="memberSelection"
                :data-source="companyDetList.companyManagements">
          
          <span slot="serial" slot-scope="text, record, index">{{ index + 1 }}</span>
          
          <span slot="action" slot-scope="text, record, index" v-if="type=='add'|| type=='edit'">
                <template>
                <a   @click="editMember(record, index)">编辑</a>
                </template>
              </span>
        </a-table>
      </a-row>
    </div>
    <title-name style="margin-top:20px" title="近三年主要业绩"></title-name>
    <a-form-model>
      <a-row>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="年平均设计合同额(万):"
                  :labelCol="{ lg: { span: 6}, sm: { span: 18 } }"
                  :wrapperCol="{ lg: { span: 6 }, sm: { span: 18 } }">
            <BaseInputNumber v-model="companyDetList.annualMeanContractAmount" placeholder="请输入"  :disabled="type=='view'|| type=='approve'"></BaseInputNumber>
          </a-form-model-item>
        </a-col>
        <a-col :md="8" :sm="8">
          <a-form-model-item
                  label="累计规模(万)"
                  :labelCol="{ lg: { span: 6}, sm: { span: 18 } }"
                  :wrapperCol="{ lg: { span: 6 }, sm: { span: 18 } }">
            <BaseInputNumber v-model="companyDetList.addUpScale" placeholder="请输入" :disabled="type=='view'|| type=='approve'"></BaseInputNumber>
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
    <div>
      <a-row>
        <div class="table-operator">
          <a-row>
            <a-col :md="24" :sm="24">
              <a-button type="primary" :disabled="type=='view'|| type=='approve'"  @click="openMainArchive()">新增</a-button>
              <a-button type="info"  :disabled="type=='view'|| type=='approve'" @click="delArchive()">删除</a-button>
            </a-col>
          </a-row>
        </div>
        <a-table
                rowKey="id"
                :columns="columns2"
                :rowSelection="archiveSelection"
                :data-source="companyDetList.achievementsDTO">
          <span slot="serial" slot-scope="text, record, index">{{ index + 1 }}</span>
          <span slot="action" slot-scope="text, record, index" v-if="type=='add'|| type=='edit'">
                <template>
                <a v-if="type!='view'|| type!='approve'" @click="editArchive(record, index)">编辑</a>
                </template>
              </span>
        </a-table>
      </a-row>
    </div>
    <a-button style="float:right;margin-top:10px;margin-right:10px"  @click="save()" type="primary">下一步</a-button>
    <!-- </a-card> -->
     <a-modal width="1000px" :visible="mianMemberVisible" title="新增企业主要骨干人员"  @cancel="closeMember" @ok="addMember">
      <a-form-model :model="member" ref="memberForm" :rules="memberRules">
        <a-row>
          <a-col :md="12" :sm="12">
            <a-form-model-item
                    label="岗位"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                    prop="post"
                    >
                    <a-select :getPopupContainer="getPopupContainer" placeholder="请选择" v-model="member.post" :disabled="type=='view'|| type=='approve'">
                      <a-select-option value="企业负责人">企业负责人</a-select-option>
                      <a-select-option value="生产负责人">生产负责人</a-select-option>
                      <a-select-option value="财务负责人">财务负责人</a-select-option>
                      <a-select-option value="技术负责人">技术负责人</a-select-option>
                      <a-select-option value="其他">其他</a-select-option>
                    </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :md="12" :sm="12">
            <a-form-model-item
                    label="姓名"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                    prop="name" 
                    >
                    <BaseInput placeholder="请输入"  v-model="member.name" :disabled="type=='view'|| type=='approve'"></BaseInput>
            </a-form-model-item>
          </a-col>
          <a-col :md="12" :sm="12">
            <a-form-model-item
                    label="联系方式"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                    >
                    <BaseInput placeholder="请输入"  v-model="member.contact" :disabled="type=='view'|| type=='approve'"></BaseInput>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-modal>
     <a-modal width="1000px" :visible="mainArchiveVisible" title="新增近三年主要业绩"  @cancel="closeArchive" @ok="addArchive">
      <a-form-model :model="archive" ref="businessForm" :rules="businessRules">
        <a-row>
          <a-col :md="12" :sm="12">
            <a-form-model-item
                    label="工程名称"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                    prop="name"
                    >
              <BaseInput placeholder="请输入"  v-model="archive.name" :disabled="type=='view'|| type=='approve'" ></BaseInput>
            </a-form-model-item>
          </a-col>
          <a-col :md="12" :sm="12">
            <a-form-model-item
                    label="所在地"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                    prop="address"
                    >
                    <BaseInput placeholder="请输入"   v-model="archive.address" :disabled="type=='view'|| type=='approve'"></BaseInput>
            </a-form-model-item>
          </a-col>
          <a-col :md="12" :sm="12">
            <a-form-model-item
                    label="业主"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                    prop="contractor"
                    >
                    <BaseInput placeholder="请输入"  v-model="archive.contractor" :disabled="type=='view'|| type=='approve'"></BaseInput>
            </a-form-model-item>
          </a-col>
          <a-col :md="12" :sm="12">
            <a-form-model-item
                    label="设计范围"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                    prop="content"
                    >
                    <BaseInput placeholder="请输入"   v-model="archive.content" :disabled="type=='view'|| type=='approve'"></BaseInput>
            </a-form-model-item>
          </a-col>
          <a-col :md="12" :sm="12">
            <a-form-model-item
                    label="负责人"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                    prop="supervisor"
                    >
                    <BaseInput placeholder="请输入"   v-model="archive.supervisor" :disabled="type=='view'|| type=='approve'"></BaseInput>
            </a-form-model-item>
          </a-col>
          <a-col :md="12" :sm="12">
            <a-form-model-item
                    label="联系方式"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                    prop="contact"
                    >
                    <BaseInput placeholder="请输入"   v-model="archive.contact" :disabled="type=='view'|| type=='approve'"></BaseInput>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-modal>
  </div>
</template>

<script>
  import { getTypesLabel} from '@/api/commons'
  import { getCompanyList , addCompanyList , editCompanyList  } from '@/api/design/investigate/overseas'
  import { addMainmember ,editMainmember , deleteMainmember , getMainmember } from  '@/api/design/investigate/company'
  import { addAchievement, editAchievement , deleteAchievement , getAchievement } from  '@/api/design/investigate/company'
  import {deleteSurvey} from '@/api/design/investigate/index'
  import { isEmail,isTelephone, isPhone, createValidator} from '@/utils/regExpression'

  const columns = [
    {
      title: '序号',
      scopedSlots: { customRender: 'serial' }
    },
    {
      title: '资质类别',
      dataIndex: 'certType',
      ellipsis: true,
    },
    {
      title: '资质证书编号',
      dataIndex: 'certNum',
      ellipsis: true,
    },
    {
      title: '资质等级及承揽项目范围',
      dataIndex: 'certLevelScope',
      ellipsis: true,
    },
    {
      title: '操作',
      dataIndex: 'action',
      width: '150px',
      scopedSlots: { customRender: 'action' }
    }
  ]
  const columns1 = [
    {
      title: '序号',
      scopedSlots: { customRender: 'serial' }
    },
    {
      title: '岗位',
      dataIndex: 'post',
      ellipsis: true,
    },
    {
      title: '姓名',
      dataIndex: 'name',
      ellipsis: true,
    },
    {
      title: '联系方式',
      dataIndex: 'contact',
      ellipsis: true,
    },
    {
      title: '操作',
      dataIndex: 'action',
      width: '150px',
      scopedSlots: { customRender: 'action' }
    }
  ]
  const columns2 = [
    {
      title: '序号',
      scopedSlots: { customRender: 'serial' }
    },
    {
      title: '工程名称',
      dataIndex: 'name',
      ellipsis: true,
    },
    {
      title: '所在地',
      dataIndex: 'address',
      ellipsis: true,
    },
    {
      title: '业主',
      dataIndex: 'contractor',
      ellipsis: true,
    },
    {
      title: '设计范围',
      dataIndex: 'content',
      ellipsis: true,
    },
    {
      title: '负责人',
      dataIndex: 'supervisor',
      ellipsis: true,
    },
    {
      title: '联系方式',
      dataIndex: 'contact',
      ellipsis: true,
    },
    {
      title: '操作',
      dataIndex: 'action',
      width: '150px',
      scopedSlots: { customRender: 'action' }
    }
  ]
  export default {
    name:'a'+ Date.now(),
    props:["resList" ,"companyDetList"],
    data(){
      this.columns = columns
      this.columns1 = columns1
      this.columns2 = columns2
      return{
        validRules: {
          legalContact: [{ validator: createValidator(isPhone, '手机号格式不正确', false,this.validChanged), trigger: 'blur'}],
          fax: [{ validator: createValidator(isTelephone, '公司传真格式不正确', false, this.validChanged), trigger: 'blur'}],
          contactPhone: [{ validator: createValidator(isPhone, '手机号格式不正确', false,this.validChanged), trigger: 'blur'}],
        },
        businessRules: {
          name: [{required: true, message: '请输入', trigger: 'change'}],
          address: [{required: true, message: '请输入', trigger: 'change'}],
          contractor: [{required: true, message: '请输入', trigger: 'change'}],
          content: [{required: true, message: '请输入', trigger: 'change'}],
          supervisor: [{required: true, message: '请输入', trigger: 'change'}],
          contact: [{required: true, message: '请输入', trigger: 'change'},{validator: createValidator(isPhone, '手机格式不正确'), trigger: 'blur'}],
        },
        memberRules: {
          post: [{required: true, message: '请选择', trigger: 'change'}],
          name: [{required: true, message: '请输入', trigger: 'change'}],
          contact: [{required: true, message: '请输入', trigger: 'change'},{validator: createValidator(isPhone, '手机格式不正确'), trigger: 'blur'}],
        },
        editTargetIndex: null, // 编辑对象的序号
        remark:'',
        form:{},
        loading:false,
        dataSource:[],
        quilify:{},
        qualitifyList:[],
        qualify:{},
        selectedRowKeys:[],
        selectedRows:[],
        disabled:false,
        companyManagements:[],
        selectedMemberKeys:[],
        mainMemberList:[],
        selectedMember:[],
        member:{},
        archive:{},
        companyList:[],
        selectedArchiveKeys:[],
        selectedArchive:[],
        archiveList:[],
        id:'',
        mainArchiveVisible:false,
        mianMemberVisible:false
      }
    },
    computed: {
      rowSelection() {
        return {
          selectedRowKeys: this.selectedRowKeys,
          selectedRows: this.selectedRows,   // 当前行所有数据
          onChange: this.onSelectChange
        }
      },
      memberSelection(){
        return {
          selectedRowKeys: this.selectedMemberKeys,
          selectedRows: this.selectedMember,   // 当前行所有数据
          onChange: this.onMemberSelectChange
        }
      },
      archiveSelection(){
        return {
          selectedRowKeys: this.selectedArchiveKeys,
          selectedRows: this.selectedArchive,   // 当前行所有数据
          onChange: this.onArchiveSelectChange
        }
      },
      
    },
    created() {
      this.id = this.$route.query.id
      this.getTypesLabel()
      this.type = this.$route.query.type
    },
    methods:{
      validChanged(data) {
        console.log(data)
        this.$emit('validChanged', data)
      },
      /**
       * @description 生成记录ID
       */
      createRecordId() {
        const timeStamp = (new Date()).getTime()
        return `fakeId${timeStamp}`
      },
      getTypesLabel(){
        // 企业性质
        getTypesLabel({type:'17'}).then(res=>{
          this.companyList = res.data
        })
      },
      save(){
        if(this.id){
          this.companyDetList.surveyId=this.id
        }else{
          this.companyDetList.surveyId = this.resList.id
        }
        if(this.companyDetList.achievementsDTO){
          this.companyDetList.achievementsDTO.forEach(item=>{
            item.id=null
          })
        }
        if(this.companyDetList.companyManagements){
          this.companyDetList.companyManagements.forEach(item=>{
            item.id=null
          })
        }
        // this.companyDetList.companyManagements.forEach(item=>{
        //   item.id=null
        // })
        this.companyDetList.achievementsDTO = this.companyDetList.achievementsDTO
        // this.companyDetList.companyManagements = this.companyManagements
        // editList(this.form).then(res=>{

        // })
        this.$emit("submitOverseasCompany",this.companyDetList)
      },
      onSelectChange(selectedRowKeys, selectedRows) {
        this.selectedRowKeys = selectedRowKeys
        this.selectedRows = selectedRows
      },
      onMemberSelectChange(selectedMemberKeys, selectedMember) {
        this.selectedMemberKeys = selectedMemberKeys
        this.selectedMember = selectedMember
      },
      onArchiveSelectChange(selectedArchiveKeys, selectedArchive) {
        this.selectedArchiveKeys = selectedArchiveKeys
        this.selectedArchive = selectedArchive
      },
      getPopupContainer(triggerNode){
        return  triggerNode.parentNode
      },
      // 获取基本信息
      getCompanyList(){
        getCompanyList({id:this.id}).then((res)=>{
          this.companyDetList = res.data
        })
      },
      // 企业主要骨干人员
      openMainMember(){
        this.editTargetIndex = null
        this.member = {}
        this.mianMemberVisible = true
      },
      // 获取主要骨干人员
      getMainmember(){
        getMainmember({id:this.id}).then((res)=>{
          this.companyDetList.companyManagements = res.data
        })
      },
      // 新增主要骨干人员
      addMember(){
        this.$refs.memberForm.validate(valid => {
          if(!valid) return
        this.mianMemberVisible = false
        const list = this.companyDetList.companyManagements
        if(this.editTargetIndex !== null) {
          list.splice(this.editTargetIndex, 1, this.member)
        } else {
          list.push({
            ...this.member,
            id: this.createRecordId()
          })
        }
        })
      },
      // 编辑主要骨干人员
      editMember(record, index){
        this.editTargetIndex = index
        this.mianMemberVisible = true
        this.member = { ...record }
      },
      // 删除
      delMember(){
        if(this.selectedMember.length==0){
          this.$message.error("请先选择需要删除的企业主要骨干人员！")
        }else{
          let _this = this
          _this.$confirm({
            title: '警告提醒！',
            content: '确定删除所选企业主要骨干人员？',
            okType: 'danger',
            onOk() {
              _this.selectedMember.forEach(delItem=>{
                console.log(delItem)
                _this.companyDetList.companyManagements = _this.companyDetList.companyManagements.filter(items=>items.id!=delItem.id)
                console.log(_this.companyDetList.companyManagements)
              })
              _this.selectedMember = []
              _this.selectedMemberKeys = []
            },
            onCancel() {
              console.log("取消删除")
            },
          })
        }
      },
      closeMember(){
        this.mianMemberVisible = false
        this.$refs.memberForm.clearValidate()
      },
      // 主要业绩
      openMainArchive(){
        this.editTargetIndex = null
        this.archive = {}
        this.mainArchiveVisible = true
      },
      closeArchive(){
        this.mainArchiveVisible = false
        this.$refs.businessForm.clearValidate()
      },
      // 获取列表--主要业绩
      getAchievement(){
        getAchievement({id:this.id}).then(res=>{
          this.companyDetList.achievementsDTO = res.data
        })
      },
      // 新增主要业绩
      addArchive(){
        this.$refs.businessForm.validate(valid => {
          if(!valid) return
        this.mainArchiveVisible = false
        const list = this.companyDetList.achievementsDTO
        if(this.editTargetIndex !== null) {
          list.splice(this.editTargetIndex, 1, this.archive)
        } else {
          list.push({
            ...this.archive,
            id: this.createRecordId()
          })
        }
        })
      },
      // 编辑
      editArchive(record, index){
        this.editTargetIndex = index
        this.mainArchiveVisible = true
        this.archive = { ...record }
      },
    // 删除主要业绩
      delArchive(){
        if(this.selectedArchive.length==0){
          this.$message.error("请先选择需要删除的近三年主要业绩！")
        }else{
          let _this = this
          _this.$confirm({
            title: '警告提醒！',
            content: '确定删除所选近三年主要业绩？',
            okType: 'danger',
            onOk() {
              _this.selectedArchive.forEach(delItem=>{
                console.log(delItem)
                _this.companyDetList.achievementsDTO = _this.companyDetList.achievementsDTO.filter(items=>items.id!=delItem.id)
                console.log(_this.companyDetList.achievementsDTO)
              })
              _this.selectedArchive = []
              _this.selectedArchiveKeys = []
            },
            onCancel() {
              console.log("取消删除")
            },
          })
        }
      }
    }
  }
</script>

<style scoped>

</style>
